package com.se;

import java.util.ArrayList;

public class Publisher {
    int user_id;
    int[] message;
    ArrayList<Subscriber> sub_id;
    public Publisher(int user_id,int[] message) {
        this.user_id=user_id;
        this.message=message;
        this.sub_id=new ArrayList<>();
    }

    public void AddSub(Subscriber new_sub) {
        sub_id.add(new_sub);
    }

    public void publish_message() {
        for(Subscriber element:this.sub_id) {
            element.message = this.message;
        }
    }

    public int getUser_id() {
        return user_id;
    }

    public int[] getMessage() {
        return message;
    }

    public ArrayList<Subscriber> getSub_id() {
        return sub_id;
    }

    public void setMessage(int[] message) {
        this.message = message;
    }


}
